﻿using System;
using Bean.SqlSugar.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Bean.Infrastructure
{
    public static class ServiceCollectionExtensions
    {
        public static IServiceCollection AddSqlSugarClient(this IServiceCollection services, IConfiguration configuration, string sectionName = "Mysql")
        {
            services.Configure<SqlSugarOptions>(configuration.GetSection(sectionName));

            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            return services;
        }
    }
}
